package c.x.jy.service.service.impl;

import c.x.jy.dao.dto.AgreeArticleEntityDto;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.Query;

import c.x.jy.dao.dao.AgreeArticleDao;
import c.x.jy.dao.entity.AgreeArticleEntity;
import c.x.jy.service.service.AgreeArticleService;
import org.apache.commons.lang3.StringUtils;


@Service("agreeArticleService")
public class AgreeArticleServiceImpl extends ServiceImpl<AgreeArticleDao, AgreeArticleEntity> implements AgreeArticleService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        	QueryWrapper<AgreeArticleEntity> query= 	 new QueryWrapper<AgreeArticleEntity>() ;
    	if(params.get("searchKey")!=null&&params.get("searchValue")!=null&&!StringUtils.isEmpty(params.get("searchKey").toString())&&!StringUtils.isEmpty(params.get("searchValue").toString()))
    	    query.eq(  params.get("searchKey").toString(), params.get("searchValue"));
    
        IPage<AgreeArticleEntity> page = this.page(
                new Query<AgreeArticleEntity>().getPage(params),
                 query
        );

        return new PageUtils(page);
    }

    @Override
    public AgreeArticleEntityDto getByCode(String code) {
        AgreeArticleEntityDto agreeArticleEntity = getBaseMapper().getByCode(code);
        return agreeArticleEntity;
    }
}
